import aiohttp
import asyncio
import time

start = time.time()


async def get(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as res:
            await res.text()
            return res


async def request():
    url = 'https://www.httpbin.org/delay/2'
    print('Waiting for ', url)
    res = await get(url)
    print('Get res from ', url, 'res:', res)


async def main():
    tasks = [request() for _ in range(10)]
    await asyncio.gather(*tasks)


asyncio.run(main())

end = time.time()
print('Cost time:', end - start)
